/* GUI CONVERTED from reccmt.p (converter v1.75) Sat Aug 12 23:04:54 2000 */
/* reccmt.p - REPETITIVE                                                      */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                         */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                       */
/* REVISION: 7.3               LAST MODIFIED: 10/31/94   BY: WUG *GN77*       */
/* REVISION: 7.3               LAST MODIFIED: 11/03/94   BY: WUG *GN98*       */
/* REVISION: 7.3               LAST MODIFIED: 03/07/96   BY: jym *G1PZ*       */
/* REVISION: 8.5               LAST MODIFIED: 06/18/96   BY: taf *J0V0*       */
/* REVISION: 8.5      LAST MODIFIED: 11/08/97   BY: *G2Q6* Thomas Fernandes */


/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* CUMULATIVE COMPLETED MAINTENANCE                                           */

     {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reccmt_p_1 "Cum Completed"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

     define variable part like rps_part.
     define variable site like rps_site.
     define variable line like rps_line.
/*G1PZ*  define variable routing like rps_routing label "Routing". */
/*G1PZ*  define variable bom_code like rps_bom_code label "BOM Code". */
     define variable cum_completed as decimal label {&reccmt_p_1}
        format ">>>,>>>,>>9.9<<<<<<<<".
     define variable qty_to_apply as decimal.
     define variable key2 as character.

     
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
part                        colon 30
        pt_desc1            at 52 no-label
        site                        colon 30
        si_desc             at 52 no-label
        line                        colon 30
        ln_desc             at 52 no-label
/*G1PZ*     routing             colon 30 */
/*G1PZ*     bom_code            colon 30 */
        skip(1)
        cum_completed       colon 30
      SKIP(.4)  /*GUI*/
with frame a attr-space width 80 side-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



     /* SET EXTERNAL LABELS */
     setFrameLabels(frame a:handle).

     find mfc_ctrl where mfc_field = "rpc_using_new" no-lock no-error.
     if not available mfc_ctrl or mfc_logical = false then do:
        {mfmsg.i 5119 3}
        message.
        message.
        leave.
     end.

    /* DO NOT RUN PROGRAM UNLESS QAD_WKFL RECORDS HAVE */
    /* BEEN CONVERTED SO THAT QAD_KEY2 HAS NEW FORMAT  */
/*G1PZ*/ if can-find(first qad_wkfl where qad_key1 = "rpm_mstr") then do:
/*G1PZ*/   {mfmsg.i 5126 3}
/*G1PZ*/   message.
/*G1PZ*/   message.
/*G1PZ*/   leave.
/*G1PZ*/ end.

     repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.

        display
        part
        site
        line
/*G1PZ*     routing */
/*G1PZ*     bom_code */
        .

        set
        part
        site
        line
/*G1PZ*     routing */
/*G1PZ*     bom_code */
        with frame a editing:
           global_part = input part.
           global_site = input site.
/*G1PZ*        global_loc = input routing. */

           if frame-field = "part" then do:
         {mfnp05.i
         rps_mstr
         rps_part
         yes
         rps_part
         "input part"}

         if recno <> ? then do:
            display rps_part @ part
            rps_site @ site
            rps_line @ line
/*G1PZ*             rps_routing @ routing */
/*G1PZ*             rps_bom_code @ bom_code */
            .

            find pt_mstr where pt_part = rps_part no-lock.
            find si_mstr where si_site = rps_site no-lock.

            display
            pt_desc1
            si_desc.
         end.

         recno = ?.
           end.
           else
           if frame-field = "site" then do:
         {mfnp05.i
         rps_mstr
         rps_part
         "rps_part = input part"
         rps_site
         "input site"}

         if recno <> ? then do:
            display rps_part @ part
            rps_site @ site
            rps_line @ line
/*G1PZ*             rps_routing @ routing */
/*G1PZ*             rps_bom_code @ bom_code */
            .

            find pt_mstr where pt_part = rps_part no-lock.
            find si_mstr where si_site = rps_site no-lock.

            display
            pt_desc1
            si_desc.
         end.
           end.
           else
           if frame-field = "line" then do:
         {mfnp05.i
         rps_mstr
         rps_part
         "rps_part = input part and rps_site = input site"
         rps_line
         "input line"}

         if recno <> ? then do:
            display rps_part @ part
            rps_site @ site
            rps_line @ line
/*G1PZ*             rps_routing @ routing */
/*G1PZ*             rps_bom_code @ bom_code */
            .

            find pt_mstr where pt_part = rps_part no-lock.
            find si_mstr where si_site = rps_site no-lock.

            display
            pt_desc1
            si_desc.
         end.
           end.
           else do:
         readkey.
         apply lastkey.
           end.
        end.

        find pt_mstr where pt_part = part no-lock no-error.

        if not available pt_mstr then do:
           {mfmsg.i 16 3}
           next-prompt part.
           undo, retry.
        end.

        display pt_desc1.

        find si_mstr where si_site = site no-lock no-error.

        if not available si_mstr then do:
           {mfmsg.i 708 3}
           next-prompt site.
           undo, retry.
        end.

/*J0V0*/    /* CHECK USERS ACCESS TO SITE */
/*J0V0*/    {gprun.i ""gpsiver.p"" "(input site,
                     input ?,
                     output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

/*J0V0*/    if return_int = 0
/*J0V0*/    then do:
/*J0V0*/       {mfmsg.i 725 3} /* USER DOES NOT HAVE ACCESS TO THIS SITE */
/*J0V0*/       next-prompt site.
/*J0V0*/       undo, retry.
/*J0V0*/    end.

        display si_desc.

        if line > "" then do:
           find ln_mstr where ln_site = site and ln_line = line no-lock no-error.

           if not available ln_mstr then do:
         {mfmsg.i 8524 3}
         next-prompt line.
         undo, retry.
           end.

           display ln_desc.
        end.

        /*GET SCHEDULE CUM COMPLETED*/

        cum_completed = 0.

        for each rps_mstr no-lock
           where rps_part = part
             and rps_site = site
             and rps_line = line
/*G1PZ*      and rps_routing = routing */
/*G1PZ*      and rps_bom_code = bom_code */
             use-index rps_part
/*G2Q6*    break by rps_due_date: */
/*G2Q6*/      by rps_part
/*G2Q6*/      by rps_site
/*G2Q6*/      by rps_line
/*G2Q6*/      by rps_due_date:
           cum_completed = cum_completed + rps_qty_comp.
        end.

        update cum_completed.

        /*APPLY CUM COMPLETED TO THE SCHEDULE*/

        for each  rps_mstr exclusive-lock
            where rps_part = part
              and rps_site = site
              and rps_line = line
/*G1PZ*       and rps_routing = routing */
/*G1PZ*       and rps_bom_code = bom_code */
              use-index rps_part
/*G2Q6*     break by rps_due_date: */
/*G2Q6*/       by rps_part
/*G2Q6*/       by rps_site
/*G2Q6*/       by rps_line
/*G2Q6*/       by rps_due_date:
           qty_to_apply = min(rps_qty_req,cum_completed).
           rps_qty_comp = qty_to_apply.
           cum_completed = cum_completed - qty_to_apply.
        end.

        /*CANCEL THE DATE POINTER AND MARK THE REPETITIVE SCHEDULE CHANGED*/
        key2 = part + "/" + site + "/" + line + "/".

        for each qad_wkfl exclusive-lock
/*G1PZ*     where qad_key1 = "rpm_mstr" */
/*G1PZ*/    where qad_key1 = "rps_mstr"
        and qad_key2 begins key2:
           qad_datefld[1] = ?.
           qad_charfld[1] = "".
        end.
     end.
/*GUI*/ if global-beam-me-up then undo, leave.

